function freq = getFrequency(x,isPlot)
   if nargin < 2
     isPlot=0;
   end
   % sampling frequency is 200 Hz
   Fs = 200;
   % calculate the FFT of the input signal
   m = (mean(x,2));
   xdft = fft(x(:,:) - m(:,1));
   % I only need to search 1/2 of xdft for the max because x is real-valued
   xdft = xdft(1:uint16(length(x)/2+1));
   
   freq_spectrum = linspace(0,(Fs/2),length(xdft));
   [Y,I] = max(abs((xdft)));
   freq = freq_spectrum(I);
   if(isPlot)
    plot(freq_spectrum,abs(xdft))
    fprintf('Maximum occurs at %3.2f Hz.\n',freq)
   end
   
 
end